package springboot.rabbitmq.consumer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import springboot.rabbitmq.config.ConfirmConfig;

import java.nio.charset.StandardCharsets;

@Slf4j
@Component
public class WarningConsumer {
    
    // 报警消息的消费者
    @RabbitListener(queues = ConfirmConfig.WARNING_QUEUE_NAME)
    public void receiveWarningMsg(Message message){
        String msg = new String(message.getBody(), StandardCharsets.UTF_8);
        log.warn("报警发现不可路由消息：{}",msg);
    }
}
